StartSimulationEngine  "SimState/BasicObstacles.xml"

AddDifferentialDriveEntity    base1

AddBumperEntity    bumper1
	/ParentEntity:base1
	/Procedure:proc2

AddLaserRangeFinderEntity    lrf1
	/Position:0  0.4  0
	/ParentEntity:base1
//	/Procedure:proc1


AddSonarEntity    sonar1
	/Position:0  0.4  -0.3
	/ParentEntity:base1
	/Procedure:proc1

FlushScript  

base1.Go(0.35, 0.5)



while (true)
{
	print sonar1.Distances[120] 
	
	if (sonar1.Distances[120] < 1)
		base1.Go(-0.35, -0.5)

	wait 1000
}

Procedure proc1

	if (lrf1.Distances[180] < 1000)
		base1.Go(-0.35, -0.5)

End 

Procedure proc2
	
	if (bumper1.Id == 0 && bumper1.Pressed)
		base1.Go(-0.35, -0.5)

	if (bumper1.Id == 1 && bumper1.Pressed)
		base1.Go(0.35, 0.5)


End 
